
AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include( 'shared.lua' )

local v15up = Vector(0,0,15)
function ENT:PhysicsUpdate(phys,deltatime)
	
	phys:Wake()
	deltatime = FrameTime()

	if self.Crash then
		if self:GetOwner() and self:GetOwner():IsValid() then
			self:GetOwner():DestroyVehicle(nil)
		end
	end
	
	local v = self.Driver
	if v == nil or v == NULL then phys:EnableGravity(true) return SIM_NOTHING end
	if not v:IsValid() then phys:EnableGravity(true) return SIM_NOTHING end
	
	v:SetPos(self:GetPos() + v15up)
	
	local pos = self:GetPos()
	local ang = self:GetTrueAngles()
	local forward = self:GetTrueForward()
	
	self.ShadowParams={}

	if v:KeyDown( IN_FORWARD ) then
		//phys:ApplyForceCenter(self.BaseSpeed * phys:GetMass() * self:GetTrueForward())
		
		self.ShadowParams.secondstoarrive	= 1
		self.ShadowParams.pos			= pos + (self.BaseSpeed * forward)     											
		self.ShadowParams.angle			= ang
		self.ShadowParams.maxangular		= 5000
		self.ShadowParams.maxangulardamp	= 10000
		self.ShadowParams.maxspeed		= 1000000
		self.ShadowParams.maxspeeddamp		= 10000
		self.ShadowParams.dampfactor		= 0.8
		self.ShadowParams.teleportdistance	= 200         
		self.ShadowParams.deltatime		= deltatime
		phys:ComputeShadowControl(self.ShadowParams) //make them move!
		
	elseif ( v:KeyDown( IN_BACK ) ) then
		//phys:ApplyForceCenter(self.BaseSpeed/1.5 * phys:GetMass() * (self:GetTrueForward()*-1))
		
		self.ShadowParams.secondstoarrive	= 1
		self.ShadowParams.pos			= pos + (self.BaseSpeed/2 * (forward*-1))   
		self.ShadowParams.angle			= ang                                                 
		self.ShadowParams.maxangular		= 5000
		self.ShadowParams.maxangulardamp	= 10000
		self.ShadowParams.maxspeed		= 1000000
		self.ShadowParams.maxspeeddamp		= 10000
		self.ShadowParams.dampfactor		= 0.8
		self.ShadowParams.teleportdistance	= 200          
		self.ShadowParams.deltatime		= deltatime
		phys:ComputeShadowControl(self.ShadowParams) //make them move!
		
	elseif ( v:KeyDown( IN_MOVELEFT ) ) then
		//phys:AddAngleVelocity(Angle( self.TurnSpeed * deltatime * 66 , 0, 0))
		
		self.ShadowParams.secondstoarrive	= 1
		self.ShadowParams.pos			= pos   											   
		self.ShadowParams.angle			= ang + Angle( self.TurnSpeed * deltatime * 66 , 0, 0)  
		self.ShadowParams.maxangular		= 5000
		self.ShadowParams.maxangulardamp	= 10000
		self.ShadowParams.maxspeed		= 1000000
		self.ShadowParams.maxspeeddamp		= 10000
		self.ShadowParams.dampfactor		= 0.8
		self.ShadowParams.teleportdistance	= 200           
		self.ShadowParams.deltatime		= deltatime
		phys:ComputeShadowControl(self.ShadowParams) //make them move!
		
	elseif ( v:KeyDown( IN_MOVERIGHT ) ) then
		//phys:AddAngleVelocity(Angle( self.TurnSpeed * deltatime * -66 , 0, 0))
		
		self.ShadowParams.secondstoarrive	= 1
		self.ShadowParams.pos			= pos   											    
		self.ShadowParams.angle			= ang + Angle( self.TurnSpeed * deltatime * -66 , 0, 0)  
		self.ShadowParams.maxangular		= 5000
		self.ShadowParams.maxangulardamp	= 10000
		self.ShadowParams.maxspeed		= 1000000
		self.ShadowParams.maxspeeddamp		= 10000
		self.ShadowParams.dampfactor		= 0.8
		self.ShadowParams.teleportdistance	= 200           
		self.ShadowParams.deltatime		= deltatime
		phys:ComputeShadowControl(self.ShadowParams) //make them move!
		
	end
end